package com.cst.security.restApi;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/restApi")
public class RestApiController {

	private final static Logger logger = LoggerFactory.getLogger(RestApiController.class);

	/*******获取当前人的认证信息 登录后才可访问*******/
	@PostMapping("/me")
	public Object getCurrentUser(@AuthenticationPrincipal UserDetails user){
		logger.info(" into '/restApi/me' method ");
		return user;
	}

	/*****************角色才有的权限*****************/
	@PostMapping("/menu_a")
	public String menu_a(){
		logger.info(" into '/restApi/menu_a' method ");
		return "this is menu_a";
	}

	@PostMapping("/menu_b")
	public String menu_b(){
		logger.info(" into '/restApi/menu_b' method ");
		return "this is menu_b";
	}

	@PostMapping("/menu_c")
	public String menu_c(){
		logger.info(" into '/restApi/menu_c' method ");
		return "this is menu_c";
	}

	@PostMapping("/menu_d")
	public String menu_d(){
		logger.info(" into '/restApi/menu_d' method ");
		return "this is menu_d";
	}

	@PostMapping("/menu_e")
	public String menu_e(){
		logger.info(" into '/restApi/menu_e' method ");
		return "this is menu_e";
	}

	@PostMapping("/menu_f")
	public String menu_f(){
		logger.info(" into '/restApi/menu_f' method ");
		return "this is menu_f";
	}
}
